package com.readbook.service;

import com.readbook.dao.WxsycDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class WxsycService {
    @Autowired
    private WxsycDao wxsycDao;

    public List<Map<String,Object>>findycgcPage(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=wxsycDao.findycgcPage(gmap);
        return list1;
    }

    public int countycgcPage(Map<String,Object>gmap)
    {
        return wxsycDao.countycgcPage(gmap);
    }



    public List<Map<String,Object>>findwdtjPage(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=wxsycDao.findwdtjPage(gmap);
        return list1;
    }

    public int countwdtjPage(Map<String,Object>gmap)
    {
        return wxsycDao.countwdtjPage(gmap);
    }



    public int addBookxsyc(Map<String,Object>gmap)
    {
        return wxsycDao.addBookxsyc(gmap);
    }

    public int addBookJztj(Map<String,Object>gmap)
    {
        return wxsycDao.addBookJztj(gmap);
    }





    public List<Map<String,Object>>getBookClass()
    {
        List<Map<String,Object>>list1=wxsycDao.getBookClass();
        for(int i=0;i<list1.size();i++){
            Map<String,Object>maps=list1.get(i);
            String pid=maps.get("CLASSID").toString();
            List<Map<String,Object>>list2=wxsycDao.getBookClassBypid(pid);
            maps.put("list",list2);
        }
        return list1;
    }

    public Map<String,Object>getxsycDetail(Map<String,Object>gmap)
    {
        Map<String,Object>maps=wxsycDao.getxsycDetail(gmap);
        if(maps.get("YCID")!=null){
            String ycid=maps.get("YCID").toString();
            List<Map<String,Object>>list2=wxsycDao.getXsycPicture(ycid);
            maps.put("pics",list2);
        }
        return maps;
    }

    public Map<String,Object>getxsycDetailByid(Map<String,Object>gmap)
    {
        Map<String,Object>maps=wxsycDao.getxsycDetail(gmap);
        return maps;
    }


    public List<Map<String,Object>>getxsycPl(Map<String,Object>gmap)
    {
        List<Map<String,Object>>list1=wxsycDao.getxsycPl(gmap);
        return list1;
    }
    public int countxsycPl(Map<String,Object>gmap)
    {
        return wxsycDao.countxsycPl(gmap);
    }



    public int updateBookxsyc(Map<String,Object>gmap)
    {
        return wxsycDao.updateBookxsyc(gmap);
    }


    public int deletePicture(Map<String,Object>gmap)
    {
        return wxsycDao.deletePicture(gmap);
    }



    public int addBookxsycpl(Map<String,Object>gmap)
    {
        return wxsycDao.addBookxsycpl(gmap);
    }


    public int deleteXsycByycid(Map<String,Object>gmap)
    {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        gmap.put("jlscsj",df.format(new Date()));
        gmap.put("jlsczt","1");
        return wxsycDao.deleteXsycByycid(gmap);
    }


    public List<Map<String,Object>> listNewStudent(Map<String,Object>gmap)
    {
        return wxsycDao.listNewStudent(gmap);
    }

    public int addNewStudent(Map<String,Object>gmap)
    {
        return wxsycDao.addNewStudent(gmap);
    }

    public List<Map<String,Object>> listAllNewStudent()
    {
        return wxsycDao.listAllNewStudent();
    }

}


